package com.yn.pet.controller.pc.response;

import com.yn.pet.entity.AppUser;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class AppUserInfoResponse {

    @ApiModelProperty("用户id")
    private Long appUserId;

    @ApiModelProperty("用户昵称")
    private String nickName;

    @ApiModelProperty("用户头像")
    private String avatar;

    @ApiModelProperty("用户手机号")
    private String phone;

    @ApiModelProperty("创建时间")
    private String createTime;

    public static AppUserInfoResponse transform(AppUser appUser) {
        AppUserInfoResponse response = new AppUserInfoResponse();
        response.setAppUserId(appUser.getAppUserId());
        if(appUser.getNickname()!=null){
            response.setNickName(appUser.getNickname());
        }else{
            //返回前三位手机号加*加后四位
            response.setNickName(appUser.getPhone().substring(0,3)+"****"+appUser.getPhone().substring(7,11));
        }
        response.setAvatar(appUser.getAvatar());
        response.setPhone(appUser.getPhone());
        return response;
    }
}
